package com.atguigu.product.products.service.impl;

import com.atguigu.product.products.vo.respVo.item.SkuItemSaleAttrVo;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.common.utils.PageUtils;
import com.atguigu.common.utils.Query;

import com.atguigu.product.products.dao.PmsSkuSaleAttrValueDao;
import com.atguigu.product.products.entity.PmsSkuSaleAttrValueEntity;
import com.atguigu.product.products.service.PmsSkuSaleAttrValueService;


@Service("pmsSkuSaleAttrValueService")
public class PmsSkuSaleAttrValueServiceImpl extends ServiceImpl<PmsSkuSaleAttrValueDao, PmsSkuSaleAttrValueEntity> implements PmsSkuSaleAttrValueService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<PmsSkuSaleAttrValueEntity> page = this.page(
                new Query<PmsSkuSaleAttrValueEntity>().getPage(params),
                new QueryWrapper<PmsSkuSaleAttrValueEntity>()
        );

        return new PageUtils(page);
    }


    public List<SkuItemSaleAttrVo> querySaleWithAttrs(Long spuId) {
        List<SkuItemSaleAttrVo> skuItemSaleAttrVos =  this.baseMapper.querySaleWithAttrs(spuId);
        if(skuItemSaleAttrVos!=null && skuItemSaleAttrVos.size()>0){
            return skuItemSaleAttrVos;
        }
        return null;
    }

    /**
     * 根据skuId查询对应的销售属性
     * @param skuId
     * @return
     */
    public List<String> cartSkuId(Long skuId) {
        List<String> strs =   this.baseMapper.cartSkuId(skuId);
        return strs;
    }

}